package cn.android666.nopreviewcamera

import android.content.Context
import android.opengl.GLSurfaceView
import android.util.AttributeSet

class YuvGLSurfaceView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : GLSurfaceView(context, attrs) {

    private val renderer: YuvRenderer

    init {
        setEGLContextClientVersion(2)
        renderer = YuvRenderer()
        setRenderer(renderer)
        renderMode = RENDERMODE_WHEN_DIRTY
    }

    fun updateYuvData(nv21: ByteArray, width: Int, height: Int) {
        renderer.updateFrame(nv21, width, height)
        requestRender()
    }

    fun setCameraRotation(degree: Int) {
        renderer.setCameraRotation(degree)
    }

}
